﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Intel.Server.WCFLibrary
{

    public class Session
    {
        public enum UserType { NonRegUser, RegUser, SuperAdmin }
        public void Reset()
        {
            UserId = -1;
            SessionId = "";
            UserName = "";
            Type = UserType.NonRegUser;
        }
        public void Set(int userid,string id, string name, UserType t, TimeSpan Dureration)
        {
            Reset();
            UserId = userid;
            SessionId = id;
            UserName = name;
            Type = t;
            LoginTime = DateTime.Now;
            SessionDeadTime = LoginTime + Dureration;
        }
        public void UpdataDeadTime(TimeSpan Duration)
        {
            this.SessionDeadTime = DateTime.Now + Duration;
        }
        public bool IsDead()
        {
            if (SessionDeadTime < DateTime.Now)
                return true;
            else
                return false;
        }
        public string SessionId;
        public string UserName;
        public int UserId;
        public bool AllowedMouseUpload;
        public bool AllowedKeyUpload;
        public UserType Type;
        public DateTime LoginTime;
        public DateTime SessionDeadTime;
    }
}